package com.springboot.drools.service;


import com.springboot.drools.entity.Order;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.mvel2.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xiaojf
 */
@Service
public class OrderService {

    @Autowired
    private KieBase kieBase;

    public Order executeRules(Order order){
        KieSession kieSession = kieBase.newKieSession();
        kieSession.insert(order);
        kieSession.fireAllRules();
        kieSession.dispose();

        return order;
    }
}
